package prototype.demo.run;

import prototype.demo.bean.Bean1;
import prototype.demo.bean.Bean2;

import java.math.BigDecimal;
import java.util.ArrayList;

public class Run {

    public static void main(String[] args) {

        long startTime = System.currentTimeMillis();
        for (int i = 0; i < 1000000; i++) {
            Bean2 bean2 = new Bean2(1L, "真实姓名", "昵称", 1, "密码", "邮箱", "手机", new ArrayList<Long>(), new ArrayList<Long>(), new BigDecimal("9"), new BigDecimal("19"));
        }
        long endTime = System.currentTimeMillis();
        System.out.println("手动创建100个相同属性对象用时: " + (endTime - startTime)+ "毫秒");
        Bean1 bean1 = new Bean1(1L, "真实姓名", "昵称", 1, "密码", "邮箱", "手机", new ArrayList<Long>(), new ArrayList<Long>(), new BigDecimal("9"), new BigDecimal("19"));
        startTime = System.currentTimeMillis();
        for (int i = 0; i < 999999; i++) {
            try {
                bean1 = (Bean1) bean1.clone();
            } catch (CloneNotSupportedException e) {
                e.printStackTrace();
            }

        }
        endTime = System.currentTimeMillis();
        System.out.println("使用克隆方法复制100个相同属性对象用时: " + (endTime - startTime)+ "毫秒");

    }
}
